<template>
  <div id="app">
    <nav>
      <router-link to="/home">home</router-link>
      |
      <router-link to="/location">location</router-link>
      |
      <router-link to="/communication">communication</router-link>
    </nav>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: "APP",
  setup() {
    return {}
  },
  watch: {
    // 子应用告知主应用路由跳转，主应用也跳到相应路由高亮菜单栏
    $route() {
      window.$wujie?.bus.$emit("sub-route-change", "other", this.$route.path);
    },
  },
  mounted() {
    // 子应用监听主应用路由跳转
    window.$wujie?.bus.$on("other-router-change", (path) => this.$router.push(path));
  },
}
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
nav {
  padding: 30px;
  a {
    font-weight: bold;
    color: #2c3e50;
    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
